#ifndef LOGIN_ROLES_H
#define LOGIN_ROLES_H

#include <string>
#include <iostream>
#include <vector>

// 定义用户角色枚举
enum Role {
    CONSUMER,
    MERCHANT,
    DELIVERY_PERSON
};

// 用户类
class User {
public:
    User(int user_id, std::string phone, std::string password, Role role_id, std::string nickname = "")
        : user_id(user_id), phone(phone), password(password), role_id(role_id), nickname(nickname) {}

    int getUserID() const { return user_id; }
    std::string getPhone() const { return phone; }
    std::string getPassword() const { return password; }
    Role getRoleID() const { return role_id; }
    std::string getNickname() const { return nickname; }

    void setNickname(const std::string& nickname) { this->nickname = nickname; }
    void setPhone(const std::string& phone) { this->phone = phone; }
    void setPassword(const std::string& password) { this->password = password; }

private:
    int user_id;
    std::string phone;
    std::string password;
    Role role_id;
    std::string nickname;
};

// 登录模块类
class LoginModule {
public:
    LoginModule() {}
    
    bool login(const std::string& phone, const std::string& password, User& user);
    bool registerUser(const std::string& phone, const std::string& password, const std::string& nickname = "");
    bool changePassword(const std::string& phone, const std::string& oldPassword, const std::string& newPassword);
    bool changePhone(const std::string& oldPhone, const std::string& newPhone);

private:
    bool validatePhone(const std::string& phone) const;
    bool validatePassword(const std::string& password) const;

    // 模拟用户数据库
    std::vector<User> users;
};

#endif 